package impl

import (
	"context"

	"gitee.com/go-kade/go12/vblog/apps/blog"
	"gitee.com/go-kade/go12/vblog/common"
)

func (i *BlogServiceImpl) update(ctx context.Context, scope *common.Scope, ins *blog.Blog) error {
	exec := i.db.WithContext(ctx).Where("id = ?", ins.Id)

	if scope != nil {
		if scope.CreateByName != "" {
			exec = exec.Where("create_by_name = ?", scope.CreateByName)
		}
	}

	return exec.Updates(ins).Error
}
